// 实现一个 sleep 函数 比如 sleep(1000) 意味着等待1000毫秒，可从 Promise、Generator、Async/Await 等角度实现
// 1、从promise
function sleep(delay) {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve()
    }, delay)
  })
}
sleep(1000).then(console.log(1))




// 2、async
function sleep(delay) {
  return new Promise(resolve => {
    setTimeout(resolve, delay)
  })
}
async function output() {
  const out = await sleep(1000)
  console.log(1);
  return out
}
output()

